package com.bougaga.opensource.scheduler.web.dto;

import com.fasterxml.jackson.annotation.JsonFormat;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import java.time.LocalDateTime;

/**
 * 任务创建请求
 * 
 * @author bougaga
 * @since 1.0.0
 */
public class TaskCreateRequest {
    
    /**
     * 任务名称
     */
    @NotBlank(message = "Task name is required")
    private String taskName;
    
    /**
     * 任务类型
     */
    @NotBlank(message = "Task type is required")
    private String taskType;
    
    /**
     * 任务数据（JSON格式）
     */
    private String taskData;
    
    /**
     * 延迟时间（毫秒）
     */
    @Positive(message = "Delay must be positive")
    private Long delayMillis;
    
    /**
     * 执行时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime executeTime;
    
    /**
     * 任务处理器名称
     */
    private String handlerName;
    
    /**
     * 最大重试次数
     */
    @Positive(message = "Max retry count must be positive")
    private Integer maxRetryCount;
    
    /**
     * 重试间隔（毫秒）
     */
    @Positive(message = "Retry interval must be positive")
    private Long retryInterval;
    
    /**
     * 优先级（数字越小优先级越高）
     */
    private Integer priority;
    
    /**
     * 是否持久化
     */
    private Boolean persistent;
    
    /**
     * 扩展属性
     */
    private String properties;
    
    public TaskCreateRequest() {
        this.maxRetryCount = 3;
        this.retryInterval = 5000L;
        this.priority = 0;
        this.persistent = true;
    }
    
    // Getters and Setters
    public String getTaskName() {
        return taskName;
    }
    
    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }
    
    public String getTaskType() {
        return taskType;
    }
    
    public void setTaskType(String taskType) {
        this.taskType = taskType;
    }
    
    public String getTaskData() {
        return taskData;
    }
    
    public void setTaskData(String taskData) {
        this.taskData = taskData;
    }
    
    public Long getDelayMillis() {
        return delayMillis;
    }
    
    public void setDelayMillis(Long delayMillis) {
        this.delayMillis = delayMillis;
    }
    
    public LocalDateTime getExecuteTime() {
        return executeTime;
    }
    
    public void setExecuteTime(LocalDateTime executeTime) {
        this.executeTime = executeTime;
    }
    
    public String getHandlerName() {
        return handlerName;
    }
    
    public void setHandlerName(String handlerName) {
        this.handlerName = handlerName;
    }
    
    public Integer getMaxRetryCount() {
        return maxRetryCount;
    }
    
    public void setMaxRetryCount(Integer maxRetryCount) {
        this.maxRetryCount = maxRetryCount;
    }
    
    public Long getRetryInterval() {
        return retryInterval;
    }
    
    public void setRetryInterval(Long retryInterval) {
        this.retryInterval = retryInterval;
    }
    
    public Integer getPriority() {
        return priority;
    }
    
    public void setPriority(Integer priority) {
        this.priority = priority;
    }
    
    public Boolean getPersistent() {
        return persistent;
    }
    
    public void setPersistent(Boolean persistent) {
        this.persistent = persistent;
    }
    
    public String getProperties() {
        return properties;
    }
    
    public void setProperties(String properties) {
        this.properties = properties;
    }
    
    @Override
    public String toString() {
        return "TaskCreateRequest{" +
                "taskName='" + taskName + '\'' +
                ", taskType='" + taskType + '\'' +
                ", delayMillis=" + delayMillis +
                ", executeTime=" + executeTime +
                '}';
    }
}
